<template>
	<view class="owner">
		<view class="owner-interest">
			<view class="title">业主权益</view>
			<view class="content">成为业主，终身享有店铺的产权，可用于自主经营，亦可出租给他人经营，并享有店铺出租、商品销售、店铺抽奖等带来的收益</view>
		</view>
		
		<view class="owner-level">
			<view class="owner-title">— 业主级别 —</view>
			<t-table>
				<t-tr>
					<t-th>身份</t-th>
					<t-th>终身代理金额 (元)</t-th>
					<t-th>拥有店铺数 (个)</t-th>
				</t-tr>
				<t-tr v-for="item in owner" :key="item.id">
					<t-td>{{item.owner_level_name}}</t-td>
					<t-td>{{item.owner_price}}</t-td>
					<t-td>{{item.owner_shops_max}}</t-td>
				</t-tr>
			</t-table>
			
			<!-- <view class="owner-identity">
				
			</view> -->
		</view>
		
		<view class="owner-earnings">
			<!-- <view class="owner-title">— 业主6大收益 —</view> -->
			<image src="https://edsfiles.oss-cn-shenzhen.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/YEZHU.jpg" mode=""></image>
		</view>
		<!-- <view class="back" :class="{hide:popup}" @click="apply(true)"></view>
		<view class="show" :class="{hide:popup}">
			<scroll-view class="sheetView" v-for="item in owner" :key="item.id">
				<view class="owner-name" @click="navTo('/pages/owner/ownermsg?id=' + item.id +'&ownerid= '+ownerid)">{{item.owner_level_name}}</view>
			</scroll-view>
			<view class="cancel" @click="apply(true)">
				<uni-icons type="icon-shanchu1" color="#ccc" size="40"></uni-icons>
			</view>
		</view>
		<button @click="apply(false)" v-show="login == true">立即申请</button>-->
		
		<uni-popup ref="popup" type="bottom">
			<view class="show">
				<scroll-view class="sheetView" v-for="item in owner" :key="item.id">
					<view class="owner-name" @click="navTo('/pages/owner/ownermsg?id=' + item.id +'&ownerid= '+ownerid)">{{item.owner_level_name}}</view>
				</scroll-view>
				<view class="cancel" @click="close">
					<uni-icons type="icon-shanchu1" color="#ccc" size="40"></uni-icons>
				</view>
			</view>
		</uni-popup>
		<button @click="open" style="background-color: #FF3232;" v-show="login == true && uid < 1">立即申请</button>
        <button v-show="uid > 1" style="margin-bottom: 120upx; background-color: #F03232;"  plain="true" open-type="share">
        	邀请业主
        </button>
		
	</view>
</template>

<script>
	import {getOne} from '../../api/publicapi.js'
	import uniIcons from '../../ed-icons/ed-icons.vue'
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	
	export default {
		components: {
			uniIcons,
			uniPopup
		},
		data() {
			return {
				owner: [],
				login: false,
				//popup: true,
                uid:0,
                ownerid:6
			}
		},
		onShow() {
			this.ownerthapply();
		},
        onLoad(e) {
            if(e.uid!==undefined){
                 this.ownerid = e.uid
            }
        },
		methods: {
			open(){
				// 需要在 popup 组件，指定 ref 为 popup
				this.$refs.popup.open()
			},
			close(){
				// 需要在 popup 组件，指定 ref 为 popup
				this.$refs.popup.close()
			},
			navTo(url){
				uni.navigateTo({
					url
				})
			}, 
			ownerthapply(){
				getOne('front/minownerthapply',{mini:'miniowner'}).then(res => {
					this.owner = res.data.ownerconfig;
                    if(res.data.login>0){
                        this.login = true
                    }
                    this.uid = res.data.userid
                    
				})
				
			},
			// apply(e){
			// 	this.popup = e
			// },
            onShareAppMessage(res) {
            	let that = this
            	let pages = getCurrentPages();
            	let curPage = pages[pages.length - 1].route;
            	let title = '易度商城业主邀请'
            	let path = '/' + curPage+'?uid='+this.uid 
            	if (res.from === 'button') { // 来自页面内分享按钮
            		console.log(res.target)
            	}
            	console.log(path)
            	return {
            		title: title,
            		path: path,
            		imageUrl: "https://edsfiles.oss-cn-shenzhen.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%B8%9A%E4%B8%BB%E5%88%86%E4%BA%AB%E5%9B%BE%E7%89%87.png",
            		desc: '出租店铺收租金，会员抽奖有奖励，网点增值享获利，商品销售有提成。投资就来易度商城'
            	}
            }
		}
	}
</script>

<style lang="scss">
	.owner{
		.owner-interest{
			height: 260upx;
			width: 100%;
			color: #FFF;
			background: url('https://edsfiles.oss-cn-shenzhen.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20191119151850.jpg') no-repeat;
			background-size:750upx 286upx;
			padding: 30upx 10upx 20upx;
			font-size: 26upx;
			.title{
				height: 60upx;
				text-align: center;
				font-size: 36upx;
			}
			.content{
				line-height: 36upx;
				width: 93%;
				margin: auto;
			}
		}
		
		.owner-title{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			color: #FFF;
			background-color: #FF3232;
			font-size: 32rpx;
		}
		
		.owner-level{
			
			t-table{
				width: 92%;
				margin: 30upx auto;
				font-size: 28upx;
				text-align: center;
				display: block;
				border-collapse: collapse;
				border: 1upx solid #C9C9C9;
				t-tr{
					display: flex;
					justify-content: space-between;
					t-th{
						color: #FFF;
						line-height: 60upx;
						height: 60upx;
						border: 1upx solid #C9C9C9;
						width: 33%;
						background-color: #fe7636;
					}
					t-td{
						line-height: 60upx;
						height: 60upx;
						border: 1upx solid #C9C9C9;
						width: 33%;
					}
				}
				
			}
		}
		
		.owner-earnings{
			image{
				width: 750upx;
				height: 1059upx;
			}
		}
		
		button{
			color: #FFF;
			width: 60%;
			border: 0px;
			margin-bottom: 20upx;
			display: flex;
			justify-content: center;	
		}
		
		.show{
			width: 100%;
			position: fixed;
			bottom: 0rpx;
			padding: 60upx 0 0;
			border-radius: 15upx 15upx 0 0;
			background:#FFF;
			z-index: 1000;
			// uni-icons{
			// 	float: right;
			// }
			.owner-name{
				width: 86%;
				height: 72rpx;
				color: #909399;
				margin: 20rpx auto;
				border: 1px solid #ccc;
				border-radius: 45rpx;
				text-align: center;
				font-size: 34rpx;
				line-height: 60rpx
			}
			.cancel{
				height: 80upx;
				text-align: center;
				margin-top: 20upx;
			}
		}
		.hide{
			display: none;
		}
		.back{
			width: 100%;
			height: 100%;
			position: fixed;
			bottom: 0rpx;
			background:#F7F6FC;
			z-index: 999;
			background:rgba(0,0,0,0.4);
		}
	}
</style>
